<header>
    <div class="container">
        <nav class="navbar">
            <div class="logo">
                <i class="fas fa-blog"></i>
                <span>molin博客
                </span>
            </div>
            <ul class="nav-links">
                <li><a href="index.php" <?php echo basename($_SERVER['PHP_SELF']) == 'index.php' ? 'class="active"' : ''; ?>>首页</a></li>
                <?php if (isset($_SESSION['user'])): ?>
                    <li><a href="create.php" <?php echo basename($_SERVER['PHP_SELF']) == 'create.php' ? 'class="active"' : ''; ?>>写博客</a></li>
                    <li><a href="categories.php" <?php echo basename($_SERVER['PHP_SELF']) == 'categories.php' ? 'class="active"' : ''; ?>>分类管理</a></li>
                    <li><a href="profile.php" <?php echo basename($_SERVER['PHP_SELF']) == 'profile.php' ? 'class="active"' : ''; ?>>个人中心</a></li>
                    <li class="user-menu">
                        <span class="user-name"><?php echo htmlspecialchars($_SESSION['user']['display_name'] ?? $_SESSION['user']['username']); ?></span>
                        <a href="logout.php" class="logout-btn">退出</a>
                    </li>
                <?php else: ?>
                    <li><a href="login.php" <?php echo basename($_SERVER['PHP_SELF']) == 'login.php' ? 'class="active"' : ''; ?>>登录</a></li>
                <?php endif; ?>
            </ul>
        </nav>
    </div>
</header>